<template>
    <rx-dialog @handOk="handleSubmit" @cancel="cancel">
        <rx-layout>
            <div slot="center">
                <rx-grid
                    ref="table"
                    :allowRowSelect="true"
                    :multiSelect="false"
                    :columns="columns"
                    :defaultPageSize="10"
                    url="/api-form/form/core/formExcelTemplate/query"
                    :queryParam="queryParam"
                    data-field="result.data"
                    :pageSizeOptions="['10','30','40']"
                    id-field="id"
                    :selectRowKeys="selectRowKeys"
                    @selectChange="onSelectChange"
                >
                </rx-grid>
            </div>
        </rx-layout>
    </rx-dialog>
</template>

<script>
import {Util,RxDialog,RxLayout,BaseList} from "@lowcode/jpaas-common-lib";
import FormExcelTemplateApi from '@/api/form/core/formExcelTemplate'
export default {
    name: "ExcelTemplateDialog",
    components: {
        RxDialog,
        RxLayout
    },
    mixins: [BaseList],
    props: {
        boDefId: {
            type: String,
            default: ""
        },
        templateId: {
            type: String,
            default: ""
        },
        layerid: {
            type: String,
            default: ""
        },
        destroy: {
            type: Function
        },
    },
    data() {
        return {
            columns: [
                {
                    title: '序号',
                    type: 'indexColumn',
                    width: 100,
                    dataIndex: 'serial',
                    scopedSlots: {customRender: 'serial'}
                },
                {title: '名称', dataIndex: 'name', width: 100},
                {title: '业务模型名称', dataIndex: 'boName', width: 100},
                {title: '创建时间', dataIndex: 'createTime', width: 100},
            ],
            selectRowKeys:[]
        }
    },
    created(){
        this.queryParam.Q_BO_ID__S_EQ=this.boDefId?this.boDefId:"";
        if(this.templateId){
            this.selectRowKeys.push(this.templateId);
        }
    },
    mounted() {
        if(this.templateId){
            this.$refs.table.selectRowKeys = [this.templateId];
        }
    },
    methods: {
        getListByParams(parameter) {
            return FormExcelTemplateApi.query(parameter)
        },
        handleSubmit(vm){
            var row=this.$refs.table.getSelectedRow();
            if(!row){
                this.$message.warn(this.$ti18('rxMsa.masWarn.selectOneRecord',"请选择一行记录"));
                vm.loading=false;
                return ;
            }
            Util.closeWindow(this,'ok',row);
        },
        cancel(){
            Util.closeWindow(this,'cancel');
        }
    },
    watch: {},
}
</script>

<style scoped>

</style>